package com.loanapp.server.app.webapp.config;

import com.loanapp.server.app.webapp.interceptor.login.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**")//要拦截的请求
//                .excludePathPatterns("/*/*");//不拦截的请求
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**");//推荐
    }
}
